package ${package.Entity};

<#list table.importPackages as pkg>
import ${pkg};
</#list>

/**
 * <p>${table.comment} 数据实体类</p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if entityLombokModel>
@Data
<#if superEntityClass??>
@EqualsAndHashCode(callSuper = true)
</#if>
@Accessors(chain = true)
</#if>
<#if table.convert>
@Table(name="${table.name}")
</#if>
<#if superEntityClass??>
public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
<#elseif activeRecord>
public class ${entity} extends Model<${entity}> {
<#else>
public class ${entity} implements Serializable {
</#if>

    private static final long serialVersionUID = ${randomLong}L;
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
<#if field.keyFlag>
<#assign keyPropertyName="${field.propertyName}"/>
</#if>

<#if field.comment!?length gt 0>
    /**
     * ${field.comment}
     */
</#if>
<#-- -----   存在字段填充设置   ----->
<#if field.keyFlag>
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
</#if>
<#if field.convert>
    @Column(name = "${field.name}")
</#if>
<#-- 乐观锁注解 -->
<#if versionFieldName!"" == field.name>
    @Version
</#if>
<#-- 逻辑删除注解 -->
<#if logicDeleteFieldName!"" == field.name>
    @TableLogic
</#if>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#------------  END 字段循环遍历  ---------->
<#if !entityLombokModel>
<#list table.fields as field>

<#if field.comment!?length gt 0>
    /**
     * ${field.comment}
     */
</#if>
<#if field.propertyType == "boolean">
    <#assign getprefix="is"/>
<#else>
    <#assign getprefix="get"/>
</#if>
    public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
    }

<#if field.comment!?length gt 0>
    /**
     * ${field.comment}
     */
</#if>
<#if entityBuilderModel>
    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
<#else>
    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
</#if>
        this.${field.propertyName} = ${field.propertyName};
<#if entityBuilderModel>
        return this;
</#if>
    }
</#list>
</#if>

<#if entityColumnConstant>
<#list table.fields as field>
    public static final String ${field.name?upper_case} = "${field.name}";

</#list>
</#if>
<#if activeRecord>
    @Override
    protected Serializable pkVal() {
<#if keyPropertyName??>
        return this.${keyPropertyName};
<#else>
        return this.id;
</#if>
    }

</#if>
<#if !entityLombokModel>
<#if table.fields?size!=0 >
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("${entity} [");
<#list table.fields as field>
<#if field_index==0>
        builder.append("${field.propertyName}=").append(${field.propertyName});
<#else>
        builder.append(", ${field.propertyName}=").append(${field.propertyName});
</#if>
</#list>
        builder.append("]");
        return builder.toString();
    }

</#if>
</#if>
}
